package com.itheima.service;

import com.itheima.mapper.FoodPainsMapper;
import com.itheima.pojo.Combo;
import com.itheima.pojo.Combotype;
import com.itheima.pojo.Food;
import com.itheima.pojo.Foodattribute;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 林晓伟
 */
@Service
public class FoodPainsService {
    @Resource
    private FoodPainsMapper foodPainsMapper;

    /**
     * F14-菜品详情
     *
     * @param id 菜品id
     */
    public List<Food> a(String id) {
        List<Food> a = foodPainsMapper.a(id);
        List<Foodattribute> b = foodPainsMapper.b(id);
        for (Food food : a) {
            food.setFlavors(b);
        }
        return a;
    }

    /**
     * F15-套餐列表
     *
     * @param categoryId F15-套餐列表
     * @param status     状态
     */
    public List<Combo> b(String categoryId, Integer status) {
        List<Combo> c = foodPainsMapper.c(categoryId, status);
        List<Combotype> d = foodPainsMapper.d(categoryId);
        for (Combo combo : c) {
            combo.setSetmealDishes(d);
        }
        return c;
    }
}
